<h1 id="es6features">Ecmascript E6 features</h1>

<p>This section describes the small set of features Duktape borrows from the
<a href="https://people.mozilla.org/~jorendorff/es6-draft.html">current ES6 draft</a>
("Version: Rev 24, April 27, 2014 Draft").  These features are not fully compliant;
the intent is to minimize custom features and to align with the coming ES6 specification.</p>

<h2 id="es6-proto">Object.setPrototypeOf and Object.prototype.__proto__</h2>

<p><a href="https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.setprototypeof">Object.setPrototypeOf</a>
allows user to set the internal prototype of an object which is not supported in
Ecmascript E5.  The Ecmascript E6 draft also provides
<a href="https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.__proto__">Object.prototype.__proto__</a>,
an accessor property (setter/getter) which provides the same functionality
but is compatible with existing code base which has relied on a non-standard
<code>__proto__</code> property for a while.  Duktape does not support the
<a href="https://people.mozilla.org/~jorendorff/es6-draft.html#sec-__proto___-property-names-in-object-initializers">__proto__ property name in an object initializer</a>.</p>

<p>These custom features can be disabled with the feature options
<code>DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF</code> and
<code>DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY</code>.</p>

<h2 id="es6-proxy">Proxy object (subset)</h2>

<p>The Ecmascript E6 <code>Proxy</code> object allows property virtualization
and fine-grained access control for accessing an underlying plain object.
Duktape implements a strict subset of the <code>Proxy</code> object from the
ES6 draft (Rev 24).  The following traps are implemented:</p>

<table>
<thead>
<tr><th>Trap</th><th>Implemented</th><th>Notes</th></tr>
</thead>
<tbody>
<tr><td class="propname">getPrototypeOf</td><td>no</td><td></td></tr>
<tr><td class="propname">setPrototypeOf</td><td>no</td><td></td></tr>
<tr><td class="propname">isExtensible</td><td>no</td><td></td></tr>
<tr><td class="propname">preventExtension</td><td>no</td><td></td></tr>
<tr><td class="propname">getOwnPropertyDescriptor</td><td>no</td><td></td></tr>
<tr><td class="propname">defineProperty</td><td>no</td><td></td></tr>
<tr><td class="propname">has</td><td>yes</td><td><code>Object.hasOwnProperty()</code> does not invoke the trap at the moment, <code>key in obj</code> does</td></tr>
<tr><td class="propname">get</td><td>yes</td><td></td></tr>
<tr><td class="propname">set</td><td>yes</td><td></td></tr>
<tr><td class="propname">deleteProperty</td><td>yes</td><td></td></tr>
<tr><td class="propname">enumerate</td><td>yes</td><td></td></tr>
<tr><td class="propname">ownKeys</td><td>yes</td><td><code>Object.keys()</code> enumerability check limitation</td></tr>
<tr><td class="propname">apply</td><td>no</td><td></td></tr>
<tr><td class="propname">construct</td><td>no</td><td></td></tr>
</tbody>
</table>

<p>Limitations include:</p>
<ul>
<li>Only about half of the ES6 traps have been implemented.  This causes odd behavior
    if you e.g. call <code>Object.defineProperty()</code> on a proxy object.</li>
<li><code>Object.keys()</code> invokes the <code>ownKeys</code> trap, cleans up the trap
    result to a gap-free string list, but does not check that the property names returned
    by the trap are enumerable.  <code>Object.keys()</code> and <code>Object.getOwnPropertyNames()</code>
    thus currently return the same value for a proxy object implementing the <code>ownKeys</code>
    trap.</li>
<li>Proxy revocation feature of ES6 draft is not supported.</li>
<li>The target and handler objects given to <code>new Proxy()</code> cannot
    be proxy objects themselves.  ES6 poses no such limitation, but Duktape
    enforces it to simplify the internal implementation.</li>
<li>As ES6 is still in a draft phase so the subset implemented by Duktape
    may not be forwards compatible.</li>
</ul>

<p>This custom feature can be disabled with the feature option
<code>DUK_OPT_NO_ES6_PROXY</code>.</p>
